LCOV - code coverage report
Current view: top level - libreoffice/vcl/unx/generic/app - i18n_xkb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 28 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <stdio.h>
      21             : 
      22             : #include "unx/saldisp.hxx"
      23             : #include "unx/saldata.hxx"
      24             : #include "unx/i18n_xkb.hxx"
      25             : 
      26           0 : SalI18N_KeyboardExtension::SalI18N_KeyboardExtension( Display* pDisplay )
      27             :     : mbUseExtension( sal_True ),
      28           0 :       mnDefaultGroup( 0 )
      29             : {
      30           0 :     mpDisplay = pDisplay;
      31             : 
      32             :     // allow user to set the default keyboard group idx or to disable the usage
      33             :     // of x keyboard extension at all:
      34             :     //      setenv SAL_XKEYBOARDGROUP       disables keyboard extension
      35             :     //      setenv SAL_XKEYBOARDGROUP 2     sets the keyboard group index to 2
      36             :     // keyboard group index must be in [1,4], may be specified in hex or decimal
      37           0 :     static char *pUseKeyboardExtension = getenv( "SAL_XKEYBOARDGROUP" );
      38           0 :     if ( pUseKeyboardExtension != NULL )
      39             :     {
      40           0 :         mbUseExtension = pUseKeyboardExtension[0] != '\0' ;
      41           0 :         if ( mbUseExtension )
      42           0 :             mnDefaultGroup = strtol( pUseKeyboardExtension, NULL, 0 );
      43           0 :         if ( mnDefaultGroup > XkbMaxKbdGroup )
      44           0 :             mnDefaultGroup = 0;
      45             :     }
      46             : 
      47             :     // query XServer support for XKB Extension,
      48             :     // do not call XQueryExtension() / XInitExtension() due to possible version
      49             :     // clashes !
      50           0 :     if ( mbUseExtension )
      51             :     {
      52             :         int nMajorExtOpcode;
      53           0 :         int nExtMajorVersion = XkbMajorVersion;
      54           0 :         int nExtMinorVersion = XkbMinorVersion;
      55             : 
      56             :         mbUseExtension = (sal_Bool)XkbQueryExtension( mpDisplay,
      57             :             &nMajorExtOpcode, (int*)&mnEventBase, (int*)&mnErrorBase,
      58           0 :             &nExtMajorVersion, &nExtMinorVersion );
      59             :     }
      60             : 
      61             :     // query notification for changes of the keyboard group
      62           0 :     if ( mbUseExtension )
      63             :     {
      64             :         #define XkbGroupMask (  XkbGroupStateMask | XkbGroupBaseMask \
      65             :                                 | XkbGroupLatchMask | XkbGroupLockMask )
      66             : 
      67             :         mbUseExtension = XkbSelectEventDetails( mpDisplay,
      68           0 :             XkbUseCoreKbd, XkbStateNotify, XkbGroupMask, XkbGroupMask );
      69             :     }
      70             : 
      71             :     // query initial keyboard group
      72           0 :     if ( mbUseExtension )
      73             :     {
      74             :         XkbStateRec aStateRecord;
      75           0 :         XkbGetState( mpDisplay, XkbUseCoreKbd, &aStateRecord );
      76           0 :         mnGroup = aStateRecord.group;
      77             :     }
      78           0 : }
      79             : 
      80             : void
      81           0 : SalI18N_KeyboardExtension::Dispatch( XEvent* pEvent )
      82             : {
      83             :     // must the event be handled?
      84           0 :     if (   !mbUseExtension
      85             :         || (pEvent->type != mnEventBase) )
      86           0 :         return;
      87             : 
      88             :     // only handle state notify events for now, and only interested
      89             :     // in group details
      90           0 :     sal_uInt32 nXKBType = ((XkbAnyEvent*)pEvent)->xkb_type;
      91           0 :     switch ( nXKBType )
      92             :     {
      93             :         case XkbStateNotify:
      94             : 
      95           0 :             mnGroup = ((XkbStateNotifyEvent*)pEvent)->group;
      96           0 :             break;
      97             : 
      98             :         default:
      99             : 
     100             :             #if OSL_DEBUG_LEVEL > 1
     101             :             fprintf(stderr, "Got unrequested XkbAnyEvent %#x/%i\n",
     102             :                     static_cast<unsigned int>(nXKBType), static_cast<int>(nXKBType) );
     103             :             #endif
     104           0 :             break;
     105             :     }
     106             : }
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10