LCOV - code coverage report
Current view: top level - vcl/unx/generic/app - i18n_xkb.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 29 0.0 %
Date: 2014-11-03 Functions: 0 4 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(true)
      28             :     , mnDefaultGroup(0)
      29             :     , mnGroup(0)
      30             :     , mnEventBase(0)
      31             :     , mnErrorBase(0)
      32           0 :     , mpDisplay(pDisplay)
      33             : {
      34             : 
      35             :     // allow user to set the default keyboard group idx or to disable the usage
      36             :     // of x keyboard extension at all:
      37             :     //      setenv SAL_XKEYBOARDGROUP       disables keyboard extension
      38             :     //      setenv SAL_XKEYBOARDGROUP 2     sets the keyboard group index to 2
      39             :     // keyboard group index must be in [1,4], may be specified in hex or decimal
      40           0 :     static char *pUseKeyboardExtension = getenv( "SAL_XKEYBOARDGROUP" );
      41           0 :     if ( pUseKeyboardExtension != NULL )
      42             :     {
      43           0 :         mbUseExtension = pUseKeyboardExtension[0] != '\0' ;
      44           0 :         if ( mbUseExtension )
      45           0 :             mnDefaultGroup = strtol( pUseKeyboardExtension, NULL, 0 );
      46           0 :         if ( mnDefaultGroup > XkbMaxKbdGroup )
      47           0 :             mnDefaultGroup = 0;
      48             :     }
      49             : 
      50             :     // query XServer support for XKB Extension,
      51             :     // do not call XQueryExtension() / XInitExtension() due to possible version
      52             :     // clashes !
      53           0 :     if ( mbUseExtension )
      54             :     {
      55             :         int nMajorExtOpcode;
      56           0 :         int nExtMajorVersion = XkbMajorVersion;
      57           0 :         int nExtMinorVersion = XkbMinorVersion;
      58             : 
      59             :         mbUseExtension = XkbQueryExtension( mpDisplay,
      60             :             &nMajorExtOpcode, (int*)&mnEventBase, (int*)&mnErrorBase,
      61           0 :             &nExtMajorVersion, &nExtMinorVersion ) != 0;
      62             :     }
      63             : 
      64             :     // query notification for changes of the keyboard group
      65           0 :     if ( mbUseExtension )
      66             :     {
      67             :         #define XkbGroupMask (  XkbGroupStateMask | XkbGroupBaseMask \
      68             :                                 | XkbGroupLatchMask | XkbGroupLockMask )
      69             : 
      70             :         mbUseExtension = XkbSelectEventDetails( mpDisplay,
      71           0 :             XkbUseCoreKbd, XkbStateNotify, XkbGroupMask, XkbGroupMask );
      72             :     }
      73             : 
      74             :     // query initial keyboard group
      75           0 :     if ( mbUseExtension )
      76             :     {
      77             :         XkbStateRec aStateRecord;
      78           0 :         XkbGetState( mpDisplay, XkbUseCoreKbd, &aStateRecord );
      79           0 :         mnGroup = aStateRecord.group;
      80             :     }
      81           0 : }
      82             : 
      83             : void
      84           0 : SalI18N_KeyboardExtension::Dispatch( XEvent* pEvent )
      85             : {
      86             :     // must the event be handled?
      87           0 :     if (   !mbUseExtension
      88           0 :         || (pEvent->type != mnEventBase) )
      89           0 :         return;
      90             : 
      91             :     // only handle state notify events for now, and only interested
      92             :     // in group details
      93           0 :     sal_uInt32 nXKBType = ((XkbAnyEvent*)pEvent)->xkb_type;
      94           0 :     switch ( nXKBType )
      95             :     {
      96             :         case XkbStateNotify:
      97             : 
      98           0 :             mnGroup = ((XkbStateNotifyEvent*)pEvent)->group;
      99           0 :             break;
     100             : 
     101             :         default:
     102             : 
     103             :             #if OSL_DEBUG_LEVEL > 1
     104             :             fprintf(stderr, "Got unrequested XkbAnyEvent %#x/%i\n",
     105             :                     static_cast<unsigned int>(nXKBType), static_cast<int>(nXKBType) );
     106             :             #endif
     107           0 :             break;
     108             :     }
     109           0 : }
     110             : 
     111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10