ReactOS  0.4.14-dev-77-gd9e7c48
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)
 
VOID InputList_Remove (INPUT_LIST_NODE *pNode)
 
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 9 of file input_list.h.

◆ INPUT_LIST_NODE_FLAG_DEFAULT

#define INPUT_LIST_NODE_FLAG_DEFAULT   0x0008

Definition at line 11 of file input_list.h.

◆ INPUT_LIST_NODE_FLAG_DELETED

#define INPUT_LIST_NODE_FLAG_DELETED   0x0004

Definition at line 10 of file input_list.h.

◆ INPUT_LIST_NODE_FLAG_EDITED

#define INPUT_LIST_NODE_FLAG_EDITED   0x0001

Definition at line 8 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 408 of file input_list.c.

409 {
410  WCHAR szIndicator[MAX_STR_LEN];
411  INPUT_LIST_NODE *pInput;
412 
413  if (pLocale == NULL || pLayout == NULL)
414  {
415  return FALSE;
416  }
417 
418  for (pInput = _InputList; pInput != NULL; pInput = pInput->pNext)
419  {
420  if (pInput->pLocale == pLocale && pInput->pLayout == pLayout)
421  {
422  return FALSE;
423  }
424  }
425 
426  pInput = InputList_AppendNode();
427 
429 
430  pInput->pLocale = pLocale;
431  pInput->pLayout = pLayout;
432 
433  if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
435  szIndicator,
436  ARRAYSIZE(szIndicator)))
437  {
438  size_t len = wcslen(szIndicator);
439 
440  if (len > 0)
441  {
442  szIndicator[len - 1] = 0;
443  pInput->pszIndicator = _wcsdup(szIndicator);
444  }
445  }
446 
447  return TRUE;
448 }
#define TRUE
Definition: types.h:120
static INPUT_LIST_NODE * InputList_AppendNode(VOID)
Definition: input_list.c:133
static INPUT_LIST_NODE * _InputList
Definition: input_list.c:129
LOCALE_LIST_NODE * pLocale
Definition: input_list.h:18
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LAYOUT_LIST_NODE * pLayout
Definition: input_list.h:19
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
smooth NULL
Definition: ftsmooth.c:416
#define INPUT_LIST_NODE_FLAG_ADDED
Definition: input_list.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
GLenum GLsizei len
Definition: glext.h:6722
#define MAX_STR_LEN
Definition: defines.h:33
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:26
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
WCHAR * pszIndicator
Definition: input_list.h:23

Referenced by OnCommandAddDialog().

◆ InputList_Create()

VOID InputList_Create ( VOID  )

Definition at line 518 of file input_list.c.

519 {
520  INT iLayoutCount;
521  HKL *pLayoutList;
522 
523  iLayoutCount = GetKeyboardLayoutList(0, NULL);
524  pLayoutList = (HKL*) malloc(iLayoutCount * sizeof(HKL));
525 
526  if (pLayoutList != NULL)
527  {
528  if (GetKeyboardLayoutList(iLayoutCount, pLayoutList) > 0)
529  {
530  INT iIndex;
531 
532  for (iIndex = 0; iIndex < iLayoutCount; iIndex++)
533  {
534  LOCALE_LIST_NODE *pLocale = LocaleList_GetByHkl(pLayoutList[iIndex]);
535  LAYOUT_LIST_NODE *pLayout = LayoutList_GetByHkl(pLayoutList[iIndex]);
536 
537  if (pLocale != NULL && pLayout != NULL)
538  {
539  WCHAR szIndicator[MAX_STR_LEN] = { 0 };
540  INPUT_LIST_NODE *pInput;
541  HKL hklDefault;
542 
543  pInput = InputList_AppendNode();
544 
545  pInput->pLocale = pLocale;
546  pInput->pLayout = pLayout;
547  pInput->hkl = pLayoutList[iIndex];
548 
549  if (SystemParametersInfoW(SPI_GETDEFAULTINPUTLANG,
550  0,
551  (LPVOID)((LPDWORD)&hklDefault),
552  0) == FALSE)
553  {
554  hklDefault = GetKeyboardLayout(0);
555  }
556 
557  if (pInput->hkl == hklDefault)
558  {
560  }
561 
562  if (GetLocaleInfoW(LOWORD(pInput->pLocale->dwId),
564  szIndicator,
565  ARRAYSIZE(szIndicator)))
566  {
567  size_t len = wcslen(szIndicator);
568 
569  if (len > 0)
570  {
571  szIndicator[len - 1] = 0;
572  pInput->pszIndicator = _wcsdup(szIndicator);
573  }
574  }
575  }
576  }
577  }
578 
579  free(pLayoutList);
580  }
581 }
static INPUT_LIST_NODE * InputList_AppendNode(VOID)
Definition: input_list.c:133
#define free
Definition: debug_ros.c:5
LOCALE_LIST_NODE * pLocale
Definition: input_list.h:18
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LAYOUT_LIST_NODE * pLayout
Definition: input_list.h:19
int32_t INT
Definition: typedefs.h:56
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1098
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
smooth NULL
Definition: ftsmooth.c:416
LAYOUT_LIST_NODE * LayoutList_GetByHkl(HKL hkl)
Definition: layout_list.c:242
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:11
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
#define LOCALE_SABBREVLANGNAME
Definition: winnls.h:28
GLenum GLsizei len
Definition: glext.h:6722
UINT_PTR HKL
Definition: msctf.idl:101
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
#define MAX_STR_LEN
Definition: defines.h:33
uint32_t * LPDWORD
Definition: typedefs.h:57
#define malloc
Definition: debug_ros.c:4
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LOCALE_LIST_NODE * LocaleList_GetByHkl(HKL hkl)
Definition: locale_list.c:129
WCHAR * pszIndicator
Definition: input_list.h:23

Referenced by OnInitSettingsPage().

◆ InputList_Destroy()

VOID InputList_Destroy ( VOID  )

Definition at line 193 of file input_list.c.

194 {
195  INPUT_LIST_NODE *pCurrent;
196 
197  if (_InputList == NULL)
198  return;
199 
200  pCurrent = _InputList;
201 
202  while (pCurrent != NULL)
203  {
204  INPUT_LIST_NODE *pNext = pCurrent->pNext;
205 
206  free(pCurrent->pszIndicator);
207  free(pCurrent);
208 
209  pCurrent = pNext;
210  }
211 
212  _InputList = NULL;
213 }
#define free
Definition: debug_ros.c:5
static INPUT_LIST_NODE * _InputList
Definition: input_list.c:129
smooth NULL
Definition: ftsmooth.c:416
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:26
WCHAR * pszIndicator
Definition: input_list.h:23

Referenced by OnDestroySettingsPage().

◆ InputList_GetFirst()

INPUT_LIST_NODE* InputList_GetFirst ( VOID  )

Definition at line 585 of file input_list.c.

586 {
587  return _InputList;
588 }
static INPUT_LIST_NODE * _InputList
Definition: input_list.c:129

Referenced by UpdateInputListView().

◆ InputList_Process()

BOOL InputList_Process ( VOID  )

Definition at line 338 of file input_list.c.

339 {
340  INPUT_LIST_NODE *pCurrent;
341  DWORD dwIndex;
342  BOOL bRet = FALSE;
343 
344  /* Process deleted and edited input methods */
345  for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
346  {
347  if ((pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DELETED) ||
348  (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_EDITED))
349  {
350  if (UnloadKeyboardLayout(pCurrent->hkl))
351  {
352  /* Only unload the edited input method, but does not delete it from the list */
353  if (!(pCurrent->wFlags & INPUT_LIST_NODE_FLAG_EDITED))
354  {
355  InputList_RemoveNode(pCurrent);
356  }
357  }
358  }
359  }
360 
362 
363  /* Find default input method */
364  for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
365  {
366  if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
367  {
368  bRet = InputList_SetFontSubstitutes(pCurrent->pLocale->dwId);
370  break;
371  }
372  }
373 
374  if (SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG,
375  0,
376  (LPVOID)((LPDWORD)&pCurrent->hkl),
377  0))
378  {
379  DWORD dwRecipients;
380 
381  dwRecipients = BSM_ALLCOMPONENTS;
382 
384  &dwRecipients,
385  WM_INPUTLANGCHANGEREQUEST,
386  0,
387  (LPARAM)pCurrent->hkl);
388  }
389 
390  /* Add methods to registry */
391  dwIndex = 2;
392 
393  for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
394  {
395  if (pCurrent->wFlags & INPUT_LIST_NODE_FLAG_DEFAULT)
396  continue;
397 
398  InputList_AddInputMethodToUserRegistry(dwIndex, pCurrent);
399 
400  dwIndex++;
401  }
402 
403  return bRet;
404 }
#define BSM_ALLCOMPONENTS
Definition: dbt.h:47
LONG WINAPI BroadcastSystemMessageW(DWORD dwFlags, LPDWORD lpdwRecipients, UINT uiMessage, WPARAM wParam, LPARAM lParam)
Definition: message.c:3397
static INPUT_LIST_NODE * _InputList
Definition: input_list.c:129
LOCALE_LIST_NODE * pLocale
Definition: input_list.h:18
static VOID InputList_AddInputMethodToUserRegistry(DWORD dwIndex, INPUT_LIST_NODE *pNode)
Definition: input_list.c:267
BOOL InputList_SetFontSubstitutes(LCID dwLocaleId)
Definition: input_list.c:45
#define BSF_POSTMESSAGE
Definition: dbt.h:58
static BOOL InputList_PrepareUserRegistry(VOID)
Definition: input_list.c:217
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID InputList_RemoveNode(INPUT_LIST_NODE *pNode)
Definition: input_list.c:166
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:11
BOOL WINAPI UnloadKeyboardLayout(_In_ HKL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INPUT_LIST_NODE_FLAG_DELETED
Definition: input_list.h:10
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:26
uint32_t * LPDWORD
Definition: typedefs.h:57
#define INPUT_LIST_NODE_FLAG_EDITED
Definition: input_list.h:8

Referenced by OnNotifySettingsPage().

◆ InputList_Remove()

VOID InputList_Remove ( INPUT_LIST_NODE pNode)

Definition at line 478 of file input_list.c.

479 {
480  BOOL bRemoveNode = FALSE;
481 
482  if (pNode == NULL)
483  return;
484 
485  if (pNode->wFlags & INPUT_LIST_NODE_FLAG_ADDED)
486  {
487  /*
488  * If the input method has been added to the list, but not yet written
489  * in the registry, then simply remove it from the list
490  */
491  bRemoveNode = TRUE;
492  }
493  else
494  {
496  }
497 
499  {
500  if (pNode->pNext != NULL)
501  {
502  pNode->pNext->wFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
503  }
504  else if (pNode->pPrev != NULL)
505  {
506  pNode->pPrev->wFlags |= INPUT_LIST_NODE_FLAG_DEFAULT;
507  }
508  }
509 
510  if (bRemoveNode != FALSE)
511  {
512  InputList_RemoveNode(pNode);
513  }
514 }
#define TRUE
Definition: types.h:120
struct _INPUT_LIST_NODE * pPrev
Definition: input_list.h:25
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID InputList_RemoveNode(INPUT_LIST_NODE *pNode)
Definition: input_list.c:166
smooth NULL
Definition: ftsmooth.c:416
#define INPUT_LIST_NODE_FLAG_ADDED
Definition: input_list.h:9
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:11
#define INPUT_LIST_NODE_FLAG_DELETED
Definition: input_list.h:10
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:26

Referenced by OnCommandSettingsPage().

◆ InputList_SetDefault()

VOID InputList_SetDefault ( INPUT_LIST_NODE pNode)

Definition at line 452 of file input_list.c.

453 {
454  INPUT_LIST_NODE *pCurrent;
455 
456  if (pNode == NULL)
457  return;
458 
459  for (pCurrent = _InputList; pCurrent != NULL; pCurrent = pCurrent->pNext)
460  {
461  if (pCurrent == pNode)
462  {
464  }
465  else
466  {
467  pCurrent->wFlags &= ~INPUT_LIST_NODE_FLAG_DEFAULT;
468  }
469  }
470 }
static INPUT_LIST_NODE * _InputList
Definition: input_list.c:129
smooth NULL
Definition: ftsmooth.c:416
#define INPUT_LIST_NODE_FLAG_DEFAULT
Definition: input_list.h:11
struct _INPUT_LIST_NODE * pNext
Definition: input_list.h:26

Referenced by OnCommandSettingsPage().